New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

metalsmith-each

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metalsmith-each

Metalsmith plugin for easily applying a function to each file or filename.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-41.18%
Maintainers
1
Weekly downloads
 
Created
Source

metalsmith-each

A Metalsmith plugin for easily applying a function to each file or filename.

This offers a simpler API than creating a full metalsmith plugin for the common case of iterating over each file individually and doing something to the file or filename.

Installation

$ npm install metalsmith-each

Usage

Just pass a function to metalsmith-each that accepts the metalsmith file object and, optionally, the filename.

var each = require('metalsmith-each');

metalsmith.use(
  each(function (file, filename) {
    file.build_date = new Date();
  }
));

To change the filename, just return a string with the new name.

var each = require('metalsmith-each');

metalsmith.use(
  each(function (file, filename) {
    return filename.toUpperCase();
  }
));

Functions can be async, too. Just accept a done() function as the third argument. Note: If you accept the done function, you must call it or your build will hang.

var each = require('metalsmith-each');

metalsmith.use(
  each(function (file, filename, done) {
    setTimeout(function () {
      file.build_date = new Date();
      done();
    }, 1000);
  }
));

To rename a file with an async function, pass the new name to the done() function.

var each = require('metalsmith-each');

metalsmith.use(
  each(function (file, filename, done) {
    setTimeout(function () {
      done(filename.toUpperCase());
    }, 1000);
  }
));

License

MIT

Keywords

FAQs

Package last updated on 31 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc